package com.android.gl2jni.filter;

import android.content.Context;
import android.opengl.GLES20;
import com.android.gl2jni.ShaderUtils;

/**
 * Create time: 2018/9/15.
 */
public class KuwaharaFilterProgram extends TextureFilterProgram {
  int radius = 3;
  int mRadiusLocation;

  /**
   * Prepares the program in the current EGL context.
   */
  public KuwaharaFilterProgram(Context context) {
    super(context, ProgramType.TEXTURE_EXT);
  }

  public void setRadius(int radius) {
    this.radius = radius;
  }

  @Override
  protected void initProgram() {
    super.initProgram();
    mRadiusLocation = getUniformLocation("radius");
  }

  @Override
  protected String getFragmentShaderSourceEXT() {
    return ShaderUtils.readAssetsTextFile(getContext(),
        "filter/fsh/shadertoy/kuwahara.glsl");
  }

  @Override
  protected void onDraw(int firstVertex, int vertexCount) {
    setInt(mRadiusLocation, radius);
    super.onDraw(firstVertex, vertexCount);
  }

}
